﻿using System.Collections.Generic;
using System.Linq;
using RayDen.Library.Core.Primitives;

namespace RayDen.Library.Components
{
    public class BaseTriangleMeshInfo
    {
        protected HashSet<int> tIndexes;
        public string MeshName { get; set; }
        public string MaterialName { get; set; }
        public int MaterialID { get; set; }
        public int StartTriangle { get; set; }
        public int EndTriangle { get; set; }
        public int StartVertice, VerticesOffset;
        public int EndVertice;
        public float Area;
        public AABB Bounds;
        public int TrianglesCount { get { return EndTriangle - StartTriangle; } }

        public bool HasNormals { get; set; }
        public bool HasTexCoords { get; set; }

        public BaseTriangleMeshInfo()
        {
            
        }
        public BaseTriangleMeshInfo(BaseTriangleMeshInfo m)
        {
            this.Area = m.Area;
            this.Bounds = m.Bounds;
            this.EndTriangle = m.EndTriangle;
            this.EndVertice = m.EndVertice;
            this.HasNormals = m.HasNormals;
            this.HasTexCoords = m.HasTexCoords;
            this.MaterialID = m.MaterialID;
            this.MaterialName = m.MaterialName;
            this.MeshName = m.MeshName;
            this.StartTriangle = m.StartTriangle;
            this.StartVertice = m.StartVertice;
            this.VerticesOffset = m.VerticesOffset;
            this.tIndexes = m.tIndexes;
        }

        public void InitMesh(int startVertice, int endVertice, int startTri, int endTri, int vOffset)
        {
            StartVertice = startVertice;
            EndVertice = endVertice;
            StartTriangle = startTri;
            EndTriangle = endTri;
            VerticesOffset = vOffset;
            tIndexes = new HashSet<int>(Enumerable.Range(startTri, endTri - startTri));

        }

    }
}